﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />

    <title>流程-事件</title>
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" />
    <link href="../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />

    <link href="../../Style/skin/css/Default.css" rel="stylesheet" />
    <link href="../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />

    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <script src="../Admin.js"></script>
    <style type="text/css">
        caption {
            text-align: left;
            font-family: 'Microsoft YaHei';
            font-weight: bolder;
            border-bottom: none;
            margin-bottom: 10px;
        }
    </style>
    <script type="text/javascript">
        //页面启动函数.
        $(function () {

            $("#Msg").html("正在加载,请稍后......");

            //初始化groupID.
            var flowNo = GetQueryString("FK_Flow");

            var ens = new Entities("BP.Sys.FrmEvents");
            ens.Retrieve("FK_Flow", flowNo, "EventSource", 1);

            //修改流程事件
            var flow = new Entity("BP.WF.Flow", flowNo)
            flow.SetPara("FrmEventsNum", ens.length);
            flow.Update();


            var html = "<table class='table table-bordered table-striped table-hover table-condensed' style='width:100%;'>";

            html += "<tr>";
            html += "<th>序</th>";
            html += "<th>事件标记</th>";
            html += "<th>事件</th>";
            html += "<th>类型</th>";
            html += "<th>内容</th>";
            html += "<th>操作</th>";
            html += "</tr>";

            for (var i = 0; i < ens.length; i++) {

                var en = ens[i];

                html += "<tr>";
                html += "<td class=Idx>" + (i + 1) + "</td>";
                html += "<td>" + en.EventID + "</td>";
                html += "<td>" + GetActionTypeName(en.FK_Event) + "</td>";
                html += "<td>" + GetDoType(en.EventDoType) + "</td>";
                html += "<td>" + en.DoDoc + "</td>";
                html += "<td><a  href=\"javascript:Delete('" + en.MyPK + "')\"><img src='../../../WF/Img/Btn/Delete.gif' border=0 />删除</a></td>";
                html += "</tr>";
            }
            html += "</table>";

            $("#Msg").html(html);
        });

        function New() {
            var url = "ActionDtl.htm?FK_Flow=" + GetQueryString("FK_Flow");
            SetHref(url);
        }

        function Delete(mypk) {

            if (confirm('您确定要删除吗？') == false)
                return;

            var en = new Entity("BP.Sys.FrmEvent", mypk);
            en.Delete();
            Reload();
            return;
        }
        function GetActionTypeName(type) {

            //事件类型.
            var eventLists = [
                { No: "FlowOnCreateWorkID", Name: "创建工作ID后", IsHaveMsg: 1, Note: '到达当前的工作的时候.' },
                { No: "FlowOverBefore", Name: "流程结束前", IsHaveMsg: 0, Note: '发送前事件，可以抛出异常阻止流程向下发送.' },
                { No: "FlowOverAfter", Name: "流程结束后", IsHaveMsg: 1, Note: '成功的事件.' },
                { No: "BeforeFlowDel", Name: "流程删除前", IsHaveMsg: 0, Note: '失败后的处理业务.' },
                { No: "AfterFlowDel", Name: "流程删除后", IsHaveMsg: 0, Note: '退回前的业务逻辑，可以抛出异常阻止退回.' }
            ]

            for (var i = 0; i < eventLists.length; i++) {
                var en = eventLists[i];
                if (en.No == type)
                    return en.Name;
            }
            return "xxxx";
        }

        function GetDoType(doType) {

            var cfg = "@0=禁用@1=执行存储过程@2=执行SQL语句@3=执行URL@4=WebServices(未完成)@5=执行ddl文件的类与方法@6=EventBase类@7=业务单元@8=自定义WebApi";

            var cfgs = cfg.split('@');

            for (var i = 0; i < cfgs.length; i++) {
                var vss = cfgs[i];
                if (vss.indexOf('=') == -1)
                    continue;
                var vals = vss.split('=');
                if (vals[0] == doType)
                    return vals[1];
            }
            return doType + 'ss';
        }
        function Help() {
            var url = "http://doc.ccbpm.cn";
            window.open(url);
        }
    </script>
</head>
<body>
    <div class="container-full">

        <div id="titleH4" class="attrnode-bar-header">
            <span class="pull-right">
                <button id="Btn_New" class="cc-btn-tab btn-new" onclick="javascript:New()">新建流程事件</button>
                <button id="Btn_Help" class="cc-btn-tab btn-hlep" onclick="javascript:Help()">什么是流程事件?</button>
            </span>
            <strong>流程事件 </strong>
        </div>
        <form id="cc">
            <!--div style="right:30px; position:absolute; z-index:100; ">
                <input id="Btn_New" type=button value="新建流程事件" onclick="javascript:New()" />
                <input id="Btn_Help" type=button value="什么是流程事件？" onclick="javascript:Help()" />
            </!--div-->
            <div style="position:relative;" id="Msg"></div>

            <br />

        </form>
    </div>
</body>
</html>
